package per.jdz.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import per.jdz.entity.auth.Account;
import per.jdz.entity.user.AccountUser;

/**
 * ClassName: UserMapper
 * Description:
 *
 * @Author: jdz
 * @Create: 2023/4/19 - 15:49
 */
@Mapper
public interface UserMapper {
    /**
     * 根据用户名或邮箱查找用户
     * @param text
     * @return
     */
    @Select("select * from user where username = #{text} or email = #{text}")
    Account findAccountByNameOrEmail(String text);
    @Select("select * from user where username = #{text} or email = #{text}")
    AccountUser findAccountUserByNameOrEmail(String text);
    /**
     * 添加用户信息
     * @param username
     * @param password
     * @param email
     * @return
     */
    @Insert("insert into user(username, password, email) values (#{username}, #{password}, #{email})")
    int CreateAccount(String username, String password, String email);

    @Update("update user set password = #{password} where email = #{email}")
    int resetPasswordByEmail(String password, String email);
}
